/* $Id: ServiceDomainObjectManagerImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.domain.manager.provider;

import java.util.Collection;
import java.util.List;

import ae.pcfc.etks.online.common.dao.ServiceDAO;
import ae.pcfc.etks.online.common.dao.ServiceReqDAO;
import ae.pcfc.etks.online.common.dao.ServiceRoleDAO;
import ae.pcfc.etks.online.common.domain.Client;
import ae.pcfc.etks.online.common.domain.ClientServiceRole;
import ae.pcfc.etks.online.common.domain.Service;
import ae.pcfc.etks.online.common.domain.ServiceReq;
import ae.pcfc.etks.online.common.domain.ServiceRole;
import ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager;
import ae.pcfc.etks.online.common.exception.LookupException;
import ae.pcfc.etks.online.common.exception.PersistenceException;
import ae.pcfc.etks.online.common.vo.PagingVO;

public class ServiceDomainObjectManagerImpl implements ServiceDomainObjectManager {

	public ServiceDAO serviceDAO;
	public ServiceRoleDAO serviceRoleDAO;

	public ServiceReqDAO serviceReqDAO;

	/**
	 * setServiceDAO
	 * 
	 * @param serviceDAO
	 * void
	 */
	public void setServiceDAO(ServiceDAO serviceDAO) {
		this.serviceDAO = serviceDAO;
	}

	/**
	 * setServiceRoleDAO
	 * 
	 * @param serviceRoleDAO
	 * void
	 */
	public void setServiceRoleDAO(ServiceRoleDAO serviceRoleDAO) {
		this.serviceRoleDAO = serviceRoleDAO;
	}

	/**
	 * setServiceReqDAO
	 * 
	 * @param serviceReqDAO
	 * void
	 */
	public void setServiceReqDAO(ServiceReqDAO serviceReqDAO) {
		this.serviceReqDAO = serviceReqDAO;
	}

	/**
	 * add
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#add(java.lang.Object)
	 * 
	 */
	public <T> void add(T obj) throws PersistenceException {
		// TODO Auto-generated method stub

	}

	/**
	 * update
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#update(java.lang.Object)
	 * 
	 */
	public <T> void update(T obj) throws PersistenceException {
		
		this.serviceDAO.udpate((Service)obj);

	}

	/**
	 * delete
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#delete(java.lang.Object)
	 * 
	 */
	public <T> void delete(T obj) throws PersistenceException {

		this.serviceDAO.delete((Service) obj);

	}

	/**
	 * findByPrimaryKey
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#findByPrimaryKey(java.lang.String)
	 * 
	 */
	@SuppressWarnings("unchecked")
	public <T> T findByPrimaryKey(String id) throws LookupException {

		return (T) this.serviceDAO.findServiceByPrimaryKey(Long.parseLong(id));
	}

	/**
	 * findAll
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#findAll()
	 * 
	 */
	public <T> Collection<T> findAll() throws LookupException {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * add
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#add(ae.pcfc.etks.online.common.domain.Service)
	 * 
	 */
	public boolean add(Service services) throws PersistenceException {
		serviceDAO.add(services);
		return true;
	}

	/**
	 * getServicesList
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#getServicesList()
	 * 
	 */
	public List<Service> getServicesList() throws LookupException {
		return serviceDAO.getServicesList();
	}

	/**
	 * getServiceByPrimaryKey
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#getServiceByPrimaryKey(java.lang.Long)
	 * 
	 */
	public Service getServiceByPrimaryKey(Long Id) throws LookupException {
		return serviceDAO.getServiceByPrimaryKey(Id);
	}

	/**
	 * deleteServiceById
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#deleteServiceById(java.lang.Long)
	 * 
	 */
	public boolean deleteServiceById(Long Id) throws PersistenceException {
		serviceDAO.deleteServiceById(Id);
		return true;
	}

	/**
	 * findServiceByServiceRoleIds
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceByServiceRoleIds(java.util.List, java.lang.String)
	 * 
	 */
	public List<Service> findServiceByServiceRoleIds(List<Long> serviceRoleIds, String strDefault) throws LookupException {

		return this.serviceDAO.findServiceByServiceRoleIds(serviceRoleIds, strDefault);

	}

	/**
	 * findServiceRoleByRoleIds
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceRoleByRoleIds(java.util.List)
	 * 
	 */
	public List<ServiceRole> findServiceRoleByRoleIds(List<Long> serviceRoleIds) throws LookupException {

		return this.serviceRoleDAO.findServiceRoleByRoleIds(serviceRoleIds);
	}

	/**
	 * findServiceAvailableByUserNameAndRoleIds
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceAvailableByUserNameAndRoleIds(java.lang.String, java.util.List)
	 * 
	 */
	public List<Service> findServiceAvailableByUserNameAndRoleIds(String userName, List<Long> roleIds) throws LookupException {

		return this.serviceDAO.findServiceAvailableByUserNameAndRoleIds(userName, roleIds);
	}

	/**
	 * addServiceReq
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#addServiceReq(ae.pcfc.etks.online.common.domain.ServiceReq)
	 * 
	 */
	public void addServiceReq(ServiceReq serviceReq) throws PersistenceException {

		this.serviceReqDAO.addServiceReq(serviceReq);

	}

	/**
	 * findServiceListByIds
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceListByIds(java.util.List)
	 * 
	 */
	public List<Service> findServiceListByIds(List<Long> ids) throws LookupException {

		return this.serviceDAO.findServiceListByIds(ids);
	}

	/**
	 * findServiceReqByApplicationId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceReqByApplicationId(java.lang.String)
	 * 
	 */
	public List<ServiceReq> findServiceReqByApplicationId(String applicationId) throws LookupException {

		return this.serviceReqDAO.findServiceReqByApplicationId(applicationId);
	}

	/**
	 * findServiceRoleByRoleId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceRoleByRoleId(java.lang.Long)
	 * 
	 */
	public List<ServiceRole> findServiceRoleByRoleId(Long roleId) throws LookupException {

		return this.serviceRoleDAO.findServiceRoleByRoleId(roleId);

	}

	/**
	 * addServiceRole
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#addServiceRole(ae.pcfc.etks.online.common.domain.ServiceRole)
	 * 
	 */
	public void addServiceRole(ServiceRole serviceRole) throws PersistenceException {

		this.serviceRoleDAO.add(serviceRole);

	}

	/**
	 * findServiceListByUserName
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceListByUserName(java.lang.String)
	 * 
	 */
	public List<Service> findServiceListByUserName(String userName) throws LookupException {

		return this.serviceDAO.findServiceListByUserName(userName);
	}

	/**
	 * findUserDefaultService
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findUserDefaultService()
	 * 
	 */
	public Service findUserDefaultService() throws LookupException {

		return this.serviceDAO.findUserDefaultService();
	}
	
	/**
	 * findServiceByServiceDefault
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceByServiceDefault(java.lang.String)
	 * 
	 */
	public Service findServiceByServiceDefault(String strServiceDefault) throws LookupException {

		return this.serviceDAO.findServiceByServiceDefault(strServiceDefault);
	}

	/**
	 * findServiceReqByUserAndServiceId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceReqByUserAndServiceId(java.lang.Long, java.lang.Long)
	 * 
	 */
	public ServiceReq findServiceReqByUserAndServiceId(Long userId, Long serviceId) throws LookupException {
		return this.serviceReqDAO.findServiceReqByUserAndServiceId(userId, serviceId);
	}

	/**
	 * getServicesListByPagingVO
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#getServicesListByPagingVO(ae.pcfc.etks.online.common.vo.PagingVO)
	 * 
	 */
	public List<Service> getServicesListByPagingVO(PagingVO pagingVO) throws LookupException {
		return this.serviceDAO.getServicesListByPagingVO(pagingVO);
	}

	/**
	 * findServiceRolesByServiceType
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceRolesByServiceType(java.lang.String)
	 * 
	 */
	public List<ServiceRole> findServiceRolesByServiceType(String serviceType) {
		// TODO Auto-generated method stub
		return this.serviceRoleDAO.findServiceRolesByServiceType(serviceType);
	}

	/**
	 * findServiceRolesByUserName
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceRolesByUserName(java.lang.String)
	 * 
	 */
	public List<ServiceRole> findServiceRolesByUserName(String strUserName) {
		return this.serviceRoleDAO.findServiceRolesByUserName(strUserName);
	}

	/* (non-Javadoc)
	 * @see ae.pcfc.etks.online.common.domain.manager.ServiceDomainObjectManager#findServiceRoleByClientAndRoleId(ae.pcfc.etks.online.common.domain.Client, java.lang.Long)
	 */
	public List<ClientServiceRole> findServiceRoleByClientAndRoleId(Client client,Long roleId) {
		return this.serviceRoleDAO.findServiceRoleByClientAndRoleId(client, roleId);
	}

	public List<ServiceRole> findAvailableServiceRoleByRoleIdForClient(Long roleId, Client client) {
		return this.serviceRoleDAO.findAvailableServiceRoleByRoleIdForClient(roleId, client);
	}

}
